package Observers;


import java.util.ArrayList;
import java.util.Iterator;


/**
 * <p>Title NumberGenarator</p>
 *
 * @author YiMing Liu
 * @date 2018/6/14 16:29
 * <p>Description:</p>
 */
public abstract class NumberGenerator {
    private ArrayList obersvers = new ArrayList();  //保存Observer们

    public void addObserver(Observer observer) {
        obersvers.add(observer);
    }

    public void deleteObserver(Observer observer) {
        obersvers.remove(observer);
    }

    public void notifyObserver() {
        Iterator iterator = obersvers.iterator();
        while (iterator.hasNext()) {
            Observer observer = (Observer) iterator.next();
            observer.update(this);
        }
    }

    public abstract int getNubmer();

    public abstract void execute();
}
